﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using System.Web.SessionState;

namespace Mvc3.Controllers
{
	[SessionState(SessionStateBehavior.Disabled)]
    public class SessionlessController : Controller
    {
        //
        // GET: /Sessionless/

        public ActionResult Index()
        {
			var x = Session["Wops"];
			var list = new List<string>() { "Hoho", "Aha" };
            return View(list);
        }

		public static ManualResetEvent mutex = new ManualResetEvent(false);

		public ActionResult FirstWindow()
		{
			mutex.WaitOne();

			return PartialView("FirstWindow");
		}

		public ActionResult SecondWindow()
		{
			Thread.Sleep(5000);

			return PartialView("SecondWindow");
		}

		public ActionResult ThirdWindow()
		{
			Random r = new Random();
			Thread.Sleep(r.Next(0, 1000));
			return PartialView("ThirdWindow");
		}

		public ActionResult Unlock()
		{
			mutex.Set();

			return Content(String.Empty);
		}
    }
}
